package com.min.star.service.impl;

import java.util.Arrays;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.min.star.mapper.SexaminationMapper;
import com.min.star.model.Sexamination;
import com.min.star.service.ISexaminationService;

@Service
public class SexaminationServiceImpl implements ISexaminationService {
	@Autowired
	private SexaminationMapper sexaminationMapper;

	@Override
	public Page<Sexamination> findPage(Page<Sexamination> page, Sexamination sexamination) {
		return this.sexaminationMapper.findPage(page, sexamination);
	}

	@Override
	public int delete(Long id) {
		return this.sexaminationMapper.deleteById(id);
	}

	@Override
	public int delete(String ids) {
		return this.sexaminationMapper.deleteBatchIds(Arrays.asList(ids.split(",")));
	}

	@Override
	public int add(Sexamination sexamination) {
		return this.sexaminationMapper.insert(sexamination);
	}

	@Override
	public Sexamination save(Sexamination sexamination) {
		int ret = sexaminationMapper.insert(sexamination);
		Long id = sexamination.getId();
		Sexamination info = sexaminationMapper.selectById(id);
		return info;
	}

	@Override
	public Sexamination update(@Valid Sexamination sexamination) {
		int ret = this.sexaminationMapper.updateById(sexamination);
		return this.sexaminationMapper.findById(sexamination.getId());
	}

}
